package com.lindroy.androidplayer.ui.adapter

import androidx.databinding.DataBindingUtil
import androidx.lifecycle.LifecycleOwner
import com.lindroy.androidplayer.R
import com.lindroy.androidplayer.databinding.ItemBannerBinding
import com.lindroy.androidplayer.viewmodels.BannerViewModel
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder

/**
 * @author Lin
 * @date 2022/1/12
 * @function
 */
class BannerAdapter (private val owner: LifecycleOwner): BaseBannerAdapter<BannerViewModel>(){

    override fun bindData(
        holder: BaseViewHolder<BannerViewModel>,
        data: BannerViewModel?,
        position: Int,
        pageSize: Int
    ) {
        data?.also{
            DataBindingUtil.bind<ItemBannerBinding>(holder.itemView)?.apply {
                lifecycleOwner = owner
                bannerItem = it
            }
        }
    }

    override fun getLayoutId(viewType: Int): Int  =  R.layout.item_banner
}